﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Common.Entity;
using Common.SqlSugar;
namespace Common
{
    public class Log
    {
        public static void Warn(string message)
        {
            WriteInDatabase(message, LogLevel.Warn);
        }
        public static void Debug(string message)
        {
            WriteInDatabase(message, LogLevel.Debug);

        }
        public static void Info(string message)
        {
            WriteInDatabase(message, LogLevel.Info);

        }
        public static void Error(string message)
        {
            WriteInDatabase(message, LogLevel.Error);

        }
        public static async void WriteInDatabase(string message, LogLevel logLevel)
        {
            await SqlSugarHelper.Instance.Db.Insertable<LogInfo>(new LogInfo { Info = message, LogLevel = logLevel, Time = DateTime.Now }).ExecuteCommandAsync();
        }
       
    }
}
